const { AsyncLocalStorage } = require('async_hooks')
const localStorage = new AsyncLocalStorage()

module.exports = {
  bindRequestContext(ctx, next) {
    return localStorage.run(ctx, next)
  },
  getRequestContext() {
    return localStorage.getStore()
  }
}